export default (value, type) => {
    if (!value) return '';

    let p = (s) => {
        return (s < 10 ? ('0' + s) : s);
    };

    const date = new Date(value);

    const format = {
        year: p(date.getFullYear()),
        month: p(date.getMonth() + 1),
        day: p(date.getDate()),
    };

    const time = {
        hours: p(date.getHours()),
        minutes: p(date.getMinutes()),
        seconds: p(date.getSeconds()),
    };

    let dateFormat = Object.values(format).join('-');
    let dateTime = Object.values(time).join(':');

    switch (type) {
        case 'yy-mm-ss':
            return dateFormat;
        case 'yy-mm-ss hh:mm:ss':
            return dateFormat + ' ' + dateTime;
    }

    return value;
};
